const host="https://app.vmovier.com/apiv3";
const request=function(url,data,method){
  return new Promise((resolve,reject)=>{
    wx.request({
      url: encodeURI(host+url),
      data:data,
      method:method,
      success:(result)=>{
        let re=null;
        if(result.data){//判断如果返回的结果有data 取出data
          re=result.data;
        }
        if(!re){//判断如果re为null的时候把result赋值给re
            re=result;
        }else{
          if(re.data){
            re=re.data;
          }
        }
        resolve(re);
      },
      fail:(err)=>{
        reject(err);
      }
    });
  });
}
const get=(url,data)=>{
  return request(url,data,"GET");
}
const post=(url,data)=>{
  return request(url,data,"POST");
}
module.exports={
  request,get,post
}